package com.ztjava.score.controller;

import com.jfinal.aop.Duang;
import com.jfinal.kit.Ret;
import com.jfinal.plugin.activerecord.Page;
import com.ztjava.core.Constant;
import com.ztjava.core.annotation.ControllerClass;
import com.ztjava.core.base.BaseController;
import com.ztjava.core.client.member.MobileClient;
import com.ztjava.ext.auth.annotation.UserController;
import com.ztjava.ext.auth.annotation.UserMethod;
import com.ztjava.ext.auth.bean.AuthSession;
import com.ztjava.score.model.ScoreRecord;
import com.ztjava.score.service.ScoreService;


@ControllerClass(client=MobileClient.class,path="/score")
@UserController(portal=Constant.P_MEMBER)
public class ScoreMobileController extends BaseController{
	private static ScoreService scoreService = Duang.duang(ScoreService.class);
	
	public void ajaxLoadMyRecordList(){

		AuthSession authSession = getAttr(Constant.AUTHSESSION);
		Page<ScoreRecord> pd = scoreService.getRecordPage(client,
				setParaMap(getParaMapCustom(), "user_id", authSession.getId()));
		setAttr(Constant.RESULT, Constant.SUCCESS);
		setAttr("infoList",pd.getList());
		renderJson(new String[]{Constant.RESULT,"infoList"});
	}
	
	@UserMethod
	public void addSign(){
		AuthSession authSession = getAttr(Constant.AUTHSESSION);
		Ret ret = scoreService.insertSign(authSession.getId()); 
		renderRet(ret);
	}
}
